/**
 * Contains custom JavaScript code
 */
var newUrlHolder = new Object();

function loadEmployeeSearch() {
	//alert('');
	$.get(newUrlHolder.searchRecords,{
		criteria : $('#criteria').val(),
		username : $('#input').val()
	}, function(response) {
		
 		if(!response == null) {
 			$('#tableProjectDetail').hide();
 			$('#tableUserDetail').show();
 			$('#tableUserDetail').find('tbody').remove();
 	 		
 	 		//for (var i=0; i<response.length; i++) {
 				var row = '<tr>';
 				row += '<td><input type="radio" name="index" id="index" value="'+i+'"></td>';
 				row += '<td>' + response.username + '</td>';
 				row += '<td>' + response.firstName + '</td>';
 				row += '<td>' + response.lastName + '</td>';
 				row += '<td>' + getRole(response.role) + '</td>';
 				row += '</tr>';
 		 		$('#tableUserDetail').append(row);
 	 		//}
 	 		
 	 		$('#tableUserDetail').data('model', response);
 			//toggleForms('hide'); 
 		}
 		else {
 			$('#tableProjectDetail').hide();
 			$('#tableUserDetail').hide();
 			alert("Record not Found !");
 		}
 	});
	toggleForms('hide');
}

function loadProjectSearch() {
	//alert('');
	$.get(newUrlHolder.searchRecords,{
		
		criteria : $('#criteria').val(),
		username : $('#input').val()
	}, function(response) {
		
 		if(!response == null) {
 			
 			$('#tableUserDetail').hide();
 			$('#tableProjectDetail').show();
 			$('#tableProjectDetail').find('tbody').remove();
 	 		
 	 		//for (var i=0; i<response.length; i++) {
 				var row = '<tr>';
 				row += '<td><input type="radio" name="index" id="index" value="'+i+'"></td>';
 				row += '<td>' + response.projectId + '</td>';
 				row += '<td>' + response.projectName + '</td>';
 				row += '<td>' + response.projectStartDate + '</td>';
 				row += '<td>' + response.projectEndDate + '</td>';
 				row += '</tr>';
 		 		$('#tableProjectDetail').append(row);
 	 		//}
 	 		
 	 		$('#tableProjectDetail').data('model', response);
 			//toggleForms('hide'); 
 		}
 		else {
 			$('#tableProjectDetail').hide();
 			$('#tableUserDetail').hide();
 			alert("Record not Found!");
 		}
 	});
	toggleForms('hide');
}



function getRole(role) {
	if (role == 1) {
		return 'Trainee';
	} 
	else if (role == 2) {
		return 'Junior Engineer';
	}
	 else if (role == 3) {
			return 'Software Engineer';
		}
	 else if (role == 4) {
			return 'Sr. Software Engineer';
		}
	 else if (role == 5) {
			return 'Lead';
		}
	 else if (role == 6) {
			return 'Sr. Lead';
		}
	 else if (role == 7) {
			return 'Technical Specialist';
		}
	 else if (role == 8) {
			return 'Architect';
		}
	 else if (role == 9) {
			return 'Manager';
		}
	 else if (role == 10) {
			return 'Sr. Manager';
		}
	 else {
		return 'Unknown';
	} 
}




